package Main;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;

public class Try10 {
    public static void main(String[] args) {
        Integer[] dirs = {1,2,10,4,35,16,23,32,26};
        Integer[] files = {0,15,5,18,17,9};

        String path = "D:\\temp\\outfitshowTest";
        for (int i=0;i<dirs.length;i++){
            for (int j=0;j<files.length;j++){
                File fileDir = new File(path+"\\showTest_final\\"+dirs[i]);
                fileDir.mkdir();
                File fileDir2 = new File(path+"\\showTest_final\\"+dirs[i]+"\\source");
                fileDir2.mkdir();
                File fileDir3 = new File(path+"\\showTest_final\\"+dirs[i]+"\\target");
                fileDir3.mkdir();
                copyFile(path+"\\showTest\\"+dirs[i]+"\\"+files[j]+".png",path+"\\showTest_final\\"+dirs[i]+"\\"+files[j]+".png");
                copyFile(path+"\\showTest\\"+dirs[i]+"\\source"+"\\"+"1.png",path+"\\showTest_final\\"+dirs[i]+"\\source\\"+"1.png");
                copyFile(path+"\\showTest\\"+dirs[i]+"\\target"+"\\"+files[j]+".png",path+"\\showTest_final\\"+dirs[i]+"\\target"+"\\"+files[j]+".png");
            }
        }
    }

    public static void copyFile(String oldPath, String newPath) {
        try {
            int bytesum = 0;
            int byteread = 0;
            File oldfile = new File(oldPath);
            if (oldfile.exists()) { //文件存在时
                InputStream inStream = new FileInputStream(oldPath); //读入原文件
                FileOutputStream fs = new FileOutputStream(newPath);
                byte[] buffer = new byte[1444];
                int length;
                while ((byteread = inStream.read(buffer)) != -1) {
                    bytesum += byteread; //字节数 文件大小
                    System.out.println(bytesum);
                    fs.write(buffer, 0, byteread);
                }
                inStream.close();
            }
        } catch (Exception e) {
            System.out.println("复制单个文件操作出错");
            e.printStackTrace();

        }
    }
}
